<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<input type="hidden" id="currentId" value="${productOrder.id}"><%--主订单id--%>
<%--更改办理渠道--%>
<div class="dialog-warp-ajax">
    <table class="dggui-table-info">
        <tbody>
            <tr>
                <th>当前产品：</th>
                <td id="productId" data-productId="${productOrder.productId}">${productOrder.productName}</td>
            </tr>
            <tr>
                <th>当前渠道：</th>
                <td id="channelId" data-channelId="${productOrder.channelId}">${productOrder.channelName}</td>
            </tr>
            <tr>
                <th ><span class="required">更新渠道：</span></th>
                <td>
                    <select class="dggui-select" name="channel"  id="channel"></select>
                </td>
            </tr>
            <tr >
                <th>支行：</th>
                <td>
                    <input type="text" name="updateSubBranch" id="updateSubBranch" value="${productOrder.subBranch}" class="dggui-input"/>
                </td>
            </tr>
        </tbody>
    </table>
</div>


<script type="text/javascript">

    $(document).ready(function () {
        var produtId=  $("#productId").attr("data-productId");//当前产品id
        var channelId=  $("#channelId").attr("data-channelId");//当前渠道id
        console.log("产品id"+produtId)
        dggui.use(['select2'],function () {
            var select2 = dggui.select2;
            //初始化渠道
            $.post(sysInfo.basePath + '/rzsc/processing_order/channel_by_proid.do', {id: produtId}, function (result) {
                if (result.code == 0) {
                    if(!isEmpty(result.data)){
                        var newjson =result.data;
                        console.log("根据产品id查询渠道名单   "+newjson);
                        $("#channel").append("<option value=''>请选择</option>");
                        $.each(newjson, function (i, item) {//item是一个map对象
                            if(channelId ==item.id){
                                $("#channel").append("<option value='" + item.id + "' selected>" + item.name + "</option>");
                            }else{
                                $("#channel").append("<option value='" + item.id + "' >" + item.name + "</option>");
                            }
                        });
                    }

                } else {
                    console.log("查询数据错误");;
                }
            });

            select2.render({
                placeholder: "请选择",
                allowClear: true,//清空选中
                elem: $('#channel'),
                width: "280px",
                multiple: false,// 单选false或不写该参数，多选true
            });
        });
    });
</script>

